<div class="form__wrapper">
  <div class="card" data-controller="accordion" id="accordion-title">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-title" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="title">
          <%= t("title", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-title" class="card-section">
      <div class="row column">
        <%= form.translated :text_field, :title, autofocus: true, aria: { label: :title } %>
      </div>

      <div class="row column">
        <%= form.translated :text_field, :slogan, aria: { label: :slogan } %>
      </div>

      <div class="row column">
        <%= form.number_field :weight %>
      </div>

    <div class="row">
      <div class="columns" data-controller="slug">
        <%= form.text_field :slug, help_text: t(".slug_help_html", url: decidim_form_slug_url(:conferences, form.object.slug)) %>
      </div>
      </div>

      <div class="row column">
        <%= form.translated :editor, :short_description, aria: { label: :short_description } %>
      </div>

      <div class="row column">
        <%= form.translated :editor, :description, aria: { label: :description } %>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-duration">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-duration" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="duration">
          <%= t("duration", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-duration" class="card-section">
      <div class="row column">
        <%= form.date_field :start_date %>
      </div>

      <div class="row column">
        <%= form.date_field :end_date %>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-images">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-images" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="images">
          <%= t("images", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-images" class="card-section">
      <div class="row">
        <div class="columns">
          <%= form.upload :hero_image, button_class: "button button__sm button__transparent-secondary" %>
        </div>

        <div class="columns">
          <%= form.upload :banner_image, button_class: "button button__sm button__transparent-secondary" %>
        </div>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-metadata">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-metadata" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="metadata">
          <%= t("metadata", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>
    <div id="panel-metadata" class="card-section">

      <div class="row column">
        <%= form.translated :editor, :objectives, aria: { label: :objectives } %>
      </div>

      <div class="row column">
        <%= form.text_field :location %>
      </div>

      <div class="row column">
        <%= form.check_box :show_statistics %>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-registrations">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-registrations" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="registrations">
          <%= t("registrations", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-registrations" class="card-section">
      <div class="row column">
        <%= form.check_box :registrations_enabled, data: { controller: :toggle, "toggle-toggle-value": "registrations_enabled_details" } %>
      </div>

      <div id="registrations_enabled_details" <%= form.object.registrations_enabled ? nil : "hidden" %>>
        <div class="row column">
          <p><%= t(".registrations_count", count: current_participatory_space.present? ? current_participatory_space.conference_registrations.count : 0) %></p>
          <%= form.number_field :available_slots, help_text: t(".available_slots_help") %>
        </div>

        <div class="row column" id="conference_registrations_terms">
          <%= form.translated :editor, :registration_terms, toolbar: :content, aria: { label: :registration_terms } %>
        </div>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-taxonomies">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-taxonomies" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="taxonomies">
          <%= t("taxonomies", scope: "decidim.conferences.admin.conferences.form") %>
        </h2>
      </button>
    </div>
    <div id="panel-taxonomies" class="card-section">
      <% if @form.taxonomy_filters.blank? %>
        <div class="row column">
          <p class="text-gray mr-2 mt-4">
            <%= t("no_taxonomy_filters_found", scope: "decidim.conferences.admin.conferences.form") %>
            <%= link_to(t("define_taxonomy_filters", scope: "decidim.conferences.admin.conferences.form"), decidim_admin.taxonomies_path, class: "button button__text-secondary") %>
          </p>
        </div>
      <% else %>
        <% @form.taxonomy_filters.each do |filter| %>
          <div class="row column">
            <%= filter_taxonomy_items_select_field form, :taxonomies, filter %>
          </div>
        <% end %>
      <% end %>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-visibility">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-visibility" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="visibility">
          <%= t("visibility", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-visibility" class="card-section">
      <div class="row column">
        <%= form.check_box :promoted %>
      </div>
    </div>
  </div>

  <div class="card" data-controller="accordion" id="accordion-related_spaces">
    <div class="card-divider">
      <button class="card-divider-button" data-open="true" data-controls="panel-related_spaces" type="button">
        <%= icon "arrow-right-s-line" %>
        <h2 class="card-title" id="related_spaces">
          <%= t("related_spaces", scope: "decidim.admin.conferences.form") %>
        </h2>
      </button>
    </div>

    <div id="panel-related_spaces" class="card-section">
      <div class="row column">
        <% if @form.processes_for_select %>
          <%= form.select :participatory_processes_ids,
                          options_for_select(@form.processes_for_select, selected: processes_selected ),
                          { include_blank: true },
                          { multiple: true, class: "chosen-select" } %>
        <% end %>
      </div>

      <div class="row column">
        <% if @form.assemblies_for_select %>
          <%= form.select :assemblies_ids,
                          options_for_select(@form.assemblies_for_select, selected: assemblies_selected ),
                          { include_blank: true },
                          { multiple: true, class: "chosen-select" } %>
        <% end %>
      </div>
    </div>
  </div>
</div>

<%= append_javascript_pack_tag "decidim_conferences_admin" %>
